package com.ruoyi.video.service.impl;

import java.util.*;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.video.mapper.VideoConfigMapper;
import com.ruoyi.video.domain.VideoConfig;
import com.ruoyi.video.service.IVideoConfigService;

/**
 * 配置Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-09
 */
@Service
public class VideoConfigServiceImpl implements IVideoConfigService 
{
    @Autowired
    private VideoConfigMapper videoConfigMapper;

    /**
     * 查询配置列表
     *
     * @param service 服务
     * @return 配置集合
     */
    @Override
    public Map<String, String> selectVideoServerConfig(String service){
        VideoConfig vcc = new VideoConfig();
        vcc.setService(service);
        List<VideoConfig> list = videoConfigMapper.selectVideoConfigList(vcc);
        if(StringUtils.isEmpty(list)){
            return Collections.emptyMap();
        }else{
            Map<String, String> configMap = new HashMap<>();
            for(VideoConfig config:list){
                configMap.put(config.getCode(), config.getVals());
            }
            return configMap;
        }
    }

    /**
     * 查询配置
     * 
     * @param id 配置主键
     * @return 配置
     */
    @Override
    public VideoConfig selectVideoConfigById(Long id)
    {
        return videoConfigMapper.selectVideoConfigById(id);
    }

    /**
     * 查询配置列表
     * 
     * @param videoConfig 配置
     * @return 配置
     */
    @Override
    public List<VideoConfig> selectVideoConfigList(VideoConfig videoConfig)
    {
        return videoConfigMapper.selectVideoConfigList(videoConfig);
    }

    /**
     * 新增配置
     * 
     * @param videoConfig 配置
     * @return 结果
     */
    @Override
    public int insertVideoConfig(VideoConfig videoConfig)
    {
        videoConfig.setCreateTime(new Date());
        return videoConfigMapper.insertVideoConfig(videoConfig);
    }

    /**
     * 修改配置
     * 
     * @param videoConfig 配置
     * @return 结果
     */
    @Override
    public int updateVideoConfig(VideoConfig videoConfig)
    {
        videoConfig.setUpdateTime(new Date());
        return videoConfigMapper.updateVideoConfig(videoConfig);
    }

    /**
     * 批量删除配置
     * 
     * @param ids 需要删除的配置主键
     * @return 结果
     */
    @Override
    public int deleteVideoConfigByIds(Long[] ids)
    {
        return videoConfigMapper.deleteVideoConfigByIds(ids);
    }

    /**
     * 删除配置信息
     * 
     * @param id 配置主键
     * @return 结果
     */
    @Override
    public int deleteVideoConfigById(Long id)
    {
        return videoConfigMapper.deleteVideoConfigById(id);
    }
}
